package com.congiya.example.app;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.congiya.R;

public class RedirectGetter extends Activity {
	
	TextView mText;
	
	protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.i("RedirectGetter", "called");
        
        setContentView(R.layout.ex_app_redirect_getter);

        // Watch for button clicks.
        Button btnApply = (Button)findViewById(R.id.btnApply);
        btnApply.setOnClickListener(mApplyListener);

        mText = (TextView) findViewById(R.id.editView);
    }
	
	private OnClickListener mApplyListener = new OnClickListener() {

		@Override
		public void onClick(View v) {

			SharedPreferences preferences = getSharedPreferences("RedirectData", 0);
			SharedPreferences.Editor editor = preferences.edit();
			editor.putString("text", mText.getText().toString());

			Log.i("RedirectGetter", "mText : " + mText.getText());
			
			if(editor.commit()) {
				setResult(RESULT_OK);
			}
			
			finish();
		}
		
	};
	
}
